<!DOCTYPE html>
<html><head>
	<meta charset="UTF-8">
	<meta http-equiv="x-UA-Compatible" content="ie=Edge">
   	<meta name="viewport" content="width=device-width, initial-scale=1">
   	<title>Crafty - events</title>
	<link type="text/css" rel="stylesheet" href="../craftyjs-site.css">
	<link rel="shortcut icon" href="../favicon.ico">
</head>
<body>
	<div id="header-background"> </div>
	<div id="page-frame">
	<div id="header">
		<nav class="navbar">
  			<div class="container-fluid">
  				<div class="navbar-header">
  					<a class="navbar-brand" href="../"> <img class="logo" src="../images/text-logo.png"> </a>
  					
				</div>
				<div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
					<ul class="nav navbar-nav">
						<li><a href="../">首页</a></li>
						<li><a href="../getting-started/">快速开始</a></li>
						<li><a href="../documentation/">文档</a></li>
						<li><a href="../api/">API</a></li>
						<li><a href="../components/">组件</a></li>
						<li class="emph"><a href="../#install">下载</a></li>
					</ul>
				</div>
			</div>
		</nav>
	</div>


	<div id="main">
		<div id="content" class="container">
			



<div id="docs"><div class="toc-holder" id="doc-nav"><ul id="doc-level-one"><li><a href="events.html">事件列表</a></li><li class="category">核心<ul class="category-list"><li><a href="Crafty.html">Crafty</a></li><li><a href="Crafty Core.html">Crafty Core</a></li><li><a href="Crafty-bind.html">Crafty.bind()</a></li><li><a href="Crafty-c.html">Crafty.c()</a></li><li><a href="Crafty-clone.html">Crafty.clone()</a></li><li><a href="Crafty-defineField.html">Crafty.defineField()</a></li><li><a href="Crafty-e.html">Crafty.e()</a></li><li><a href="Crafty-extend.html">Crafty.extend()</a></li><li><a href="Crafty-frame.html">Crafty.frame()</a></li><li><a href="Crafty-getVersion.html">Crafty.getVersion()</a></li><li><a href="Crafty-init.html">Crafty.init()</a></li><li><a href="Crafty-isPaused.html">Crafty.isPaused()</a></li><li><a href="Crafty-one.html">Crafty.one()</a></li><li><a href="Crafty-pause.html">Crafty.pause()</a></li><li><a href="Crafty-s.html">Crafty.s()</a></li><li><a href="Crafty-settings.html">Crafty.settings</a></li><li><a href="Crafty-stage.html">Crafty.stage</a></li><li><a href="Crafty-stop.html">Crafty.stop()</a></li><li><a href="Crafty-support.html">Crafty.support</a></li><li><a href="Crafty-trigger.html">Crafty.trigger()</a></li><li><a href="Crafty-unbind.html">Crafty.unbind()</a></li><li><a href="Crafty-uniqueBind.html">Crafty.uniqueBind()</a></li></ul></li><li class="category">2D<ul class="category-list"><li><a href="2D.html">2D</a></li><li><a href="AngularMotion.html">AngularMotion</a></li><li><a href="Collision.html">Collision</a></li><li><a href="Crafty-circle.html">Crafty.circle</a></li><li><a href="Crafty-diamondIso.html">Crafty.diamondIso</a></li><li><a href="Crafty-HashMap.html">Crafty.HashMap</a></li><li><a href="Crafty-isometric.html">Crafty.isometric</a></li><li><a href="Crafty-map.html">Crafty.map</a></li><li><a href="Crafty-math-Matrix2D.html">Crafty.math.Matrix2D</a></li><li><a href="Crafty-math-Vector2D.html">Crafty.math.Vector2D</a></li><li><a href="Crafty-polygon.html">Crafty.polygon</a></li><li><a href="Crafty-raycast.html">Crafty.raycast()</a></li><li><a href="Crafty-rectManager.html">Crafty.rectManager</a></li><li><a href="Gravity.html">Gravity</a></li><li><a href="GroundAttacher.html">GroundAttacher</a></li><li><a href="Motion.html">Motion</a></li><li><a href="Supportable.html">Supportable</a></li></ul></li><li class="category">动画<ul class="category-list"><li><a href="Crafty-easing.html">Crafty.easing</a></li><li><a href="SpriteAnimation.html">SpriteAnimation</a></li><li><a href="Tween.html">Tween</a></li></ul></li><li class="category">资源<ul class="category-list"><li><a href="Crafty-asset.html">Crafty.asset()</a></li><li><a href="Crafty-assets.html">Crafty.assets</a></li><li><a href="Crafty-imageWhitelist.html">Crafty.imageWhitelist()</a></li><li><a href="Crafty-load.html">Crafty.load()</a></li><li><a href="Crafty-paths.html">Crafty.paths()</a></li><li><a href="Crafty-removeAssets.html">Crafty.removeAssets()</a></li></ul></li><li class="category">音频<ul class="category-list"><li><a href="Crafty-audio.html">Crafty.audio</a></li></ul></li><li class="category">控制器<ul class="category-list"><li><a href="Controllable.html">Controllable</a></li><li><a href="Controls.html">Controls</a></li><li><a href="Draggable.html">Draggable</a></li><li><a href="Fourway.html">Fourway</a></li><li><a href="Jumper.html">Jumper</a></li><li><a href="Multiway.html">Multiway</a></li><li><a href="Twoway.html">Twoway</a></li></ul></li><li class="category">调试<ul class="category-list"><li><a href="Crafty-error.html">Crafty.error()</a></li><li><a href="Crafty-log.html">Crafty.log()</a></li><li><a href="DebugCanvas.html">DebugCanvas</a></li><li><a href="DebugPolygon.html">DebugPolygon</a></li><li><a href="DebugRectangle.html">DebugRectangle</a></li><li><a href="SolidAreaMap.html">SolidAreaMap</a></li><li><a href="SolidHitBox.html">SolidHitBox</a></li><li><a href="VisibleMBR.html">VisibleMBR</a></li><li><a href="WiredAreaMap.html">WiredAreaMap</a></li><li><a href="WiredHitBox.html">WiredHitBox</a></li></ul></li><li class="category">事件<ul class="category-list"><li><a href="Crafty-addEvent.html">Crafty.addEvent()</a></li><li><a href="Crafty-bind.html">Crafty.bind()</a></li><li><a href="Crafty-one.html">Crafty.one()</a></li><li><a href="Crafty-removeEvent.html">Crafty.removeEvent()</a></li><li><a href="Crafty-trigger.html">Crafty.trigger()</a></li><li><a href="Crafty-unbind.html">Crafty.unbind()</a></li><li><a href="Crafty-uniqueBind.html">Crafty.uniqueBind()</a></li></ul><div></div></li><li class="category">游戏循环<ul class="category-list"><li><a href="Crafty-timer.html">Crafty.timer</a></li></ul></li><li class="category">图形<ul class="category-list"><li><a href="Canvas.html">Canvas</a></li><li><a href="CanvasLayer.html">CanvasLayer</a></li><li><a href="Color.html">Color</a></li><li><a href="Crafty-assignColor.html">Crafty.assignColor()</a></li><li><a href="Crafty-background.html">Crafty.background()</a></li><li><a href="Crafty-createLayer.html">Crafty.createLayer()</a></li><li><a href="Crafty-defaultShader.html">Crafty.defaultShader()</a></li><li><a href="Crafty-domHelper.html">Crafty.domHelper</a></li><li><a href="Crafty-pixelart.html">Crafty.pixelart()</a></li><li><a href="Crafty-sprite.html">Crafty.sprite()</a></li><li><a href="Crafty-WebGLShader.html">Crafty.WebGLShader()</a></li><li><a href="DOM.html">DOM</a></li><li><a href="DomLayer.html">DomLayer</a></li><li><a href="HTML.html">HTML</a></li><li><a href="Image.html">Image</a></li><li><a href="Particles.html">Particles</a></li><li><a href="Renderable.html">Renderable</a></li><li><a href="Sprite.html">Sprite</a></li><li><a href="Text.html">Text</a></li><li><a href="WebGL.html">WebGL</a></li><li><a href="WebGLLayer.html">WebGLLayer</a></li></ul></li><li class="category">输入<ul class="category-list"><li><a href="AreaMap.html">AreaMap</a></li><li><a href="Button.html">Button</a></li><li><a href="Crafty-findPointerEventTargetByComponent.html">Crafty.findPointerEventTargetByComponent()</a></li><li><a href="Crafty-keyboardDispatch.html">Crafty.keyboardDispatch()</a></li><li><a href="Crafty-keydown.html">Crafty.keydown</a></li><li><a href="Crafty-keys.html">Crafty.keys</a></li><li><a href="Crafty-lastEvent.html">Crafty.lastEvent</a></li><li><a href="Crafty-mouseButtons.html">Crafty.mouseButtons</a></li><li><a href="Crafty-mouseDispatch.html">Crafty.mouseDispatch()</a></li><li><a href="Crafty-mouseWheelDispatch.html">Crafty.mouseWheelDispatch()</a></li><li><a href="Crafty-multitouch.html">Crafty.multitouch()</a></li><li><a href="Crafty-selected.html">Crafty.selected</a></li><li><a href="Crafty-touchDispatch.html">Crafty.touchDispatch()</a></li><li><a href="Keyboard.html">Keyboard</a></li><li><a href="Mouse.html">Mouse</a></li><li><a href="MouseDrag.html">MouseDrag</a></li><li><a href="Touch.html">Touch</a></li></ul></li><li class="category">杂项<ul class="category-list"><li><a href="Crafty-addEvent.html">Crafty.addEvent()</a></li><li><a href="Crafty-device.html">Crafty.device</a></li><li><a href="Crafty-removeEvent.html">Crafty.removeEvent()</a></li><li><a href="Crafty-support.html">Crafty.support</a></li></ul></li><li class="category">模型<ul class="category-list"><li><a href="Model.html">Model</a></li></ul></li><li class="category">场景<ul class="category-list"><li><a href="Crafty-scene.html">Crafty.scene()</a></li></ul></li><li class="category">舞台<ul class="category-list"><li><a href="Crafty-background.html">Crafty.background()</a></li><li><a href="Crafty-scene.html">Crafty.scene()</a></li><li><a href="Crafty-viewport.html">Crafty.viewport</a></li></ul></li><li class="category">工具<ul class="category-list"><li><a href="Crafty-math.html">Crafty.math</a></li><li><a href="Delay.html">Delay</a></li><li><a href="Storage.html">Storage</a></li></ul></li></ul></div><div id="doc-content" class="doc-page-holder"><div class="events-page"><div class="eventPageBlock"><h4>Controls</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>TriggerInputDown <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {name}</span></span>]</span></dt><dd>当一个触发组被激活时</dd></dl><dl class="trigger"><dt>TriggerInputUp <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {name, downFor}</span></span>]</span></dt><dd>当一个触发组被释放时</dd></dl><dl class="trigger"><dt>DirectionalInput <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {name, x, y}</span></span>]</span></dt><dd>当定向输入发生变化时</dd></dl></div></div></div><div class="eventPageBlock"><h4>Jumper</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>CheckJumping </dt><dd>当实体即将跳越时。该事件是由实体即将从（如果存在）跳越的对象触发的。第三方可以响应此事件并使实体跳越。</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.selected</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>CraftyFocus </dt><dd>当 Crafty 的舞台被选择时触发</dd></dl><dl class="trigger"><dt>CraftyBlur </dt><dd>当 Crafty 的舞台失去焦点时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.mouseWheelDispatch</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>MouseWheelScroll <span>[<span class="trigger-data"><span class="obj-name">Scroll direction (up | down)</span><span class="obj-props"> = { direction: +1 | -1}</span></span>]</span></dt><dd>当鼠标在舞台上滚动时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.keyboardDispatch</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>KeyDown <span>[<span class="trigger-data"><span class="obj-name">Crafty's KeyboardEvent</span><span class="obj-props"> = { key: `Crafty.keys` keyCode (Number), originalEvent: original KeyboardEvent }</span></span>]</span></dt><dd>当 DOM 'keydown' 事件触发时，在所有实体上触发。</dd></dl><dl class="trigger"><dt>KeyUp <span>[<span class="trigger-data"><span class="obj-name">Crafty's KeyboardEvent</span><span class="obj-props"> = { key: `Crafty.keys` keyCode (Number), originalEvent: original KeyboardEvent }</span></span>]</span></dt><dd>当 DOM 'keyup' 事件触发时，在所有实体上触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Mouse</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>MouseOver <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当鼠标进入时触发</dd></dl><dl class="trigger"><dt>MouseOut <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当鼠标离开时触发</dd></dl><dl class="trigger"><dt>MouseDown <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当鼠标按键按下时触发</dd></dl><dl class="trigger"><dt>MouseUp <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当鼠标按键释放时触发</dd></dl><dl class="trigger"><dt>Click <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当用户单击时触发</dd></dl><dl class="trigger"><dt>DoubleClick <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当用户双击时触发</dd></dl><dl class="trigger"><dt>MouseMove <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当鼠标进入并移动时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Touch</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>TouchStart <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {TouchPoint}</span></span>]</span></dt><dd>当实体被轻触时触发</dd></dl><dl class="trigger"><dt>TouchMove <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {TouchPoint}</span></span>]</span></dt><dd>当手指在实体上移动时触发</dd></dl><dl class="trigger"><dt>TouchCancel <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {TouchPoint}</span></span>]</span></dt><dd>当触摸事件以某种方式中断时触发</dd></dl><dl class="trigger"><dt>TouchEnd <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {null}</span></span>]</span></dt><dd>当手指在实体上释放或离开实体时触发。（不传递任何数据）</dd></dl></div></div></div><div class="eventPageBlock"><h4>.areaMap</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>NewAreaMap <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {Crafty.polygon}</span></span>]</span></dt><dd>当一个新的区域地图被分配时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>MouseDrag</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Dragging <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当实体被拖动时，将在每一帧上触发</dd></dl><dl class="trigger"><dt>StartDrag <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当拖动开始时触发</dd></dl><dl class="trigger"><dt>StopDrag <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {MouseEvent}</span></span>]</span></dt><dd>当拖动结束时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Keyboard</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>KeyDown <span>[<span class="trigger-data"><span class="obj-name">Crafty's KeyboardEvent</span><span class="obj-props"> = { key: `Crafty.keys` keyCode (Number), originalEvent: original KeyboardEvent }</span></span>]</span></dt><dd>当 DOM 'keydown' 事件触发时在所有实体上触发。</dd></dl><dl class="trigger"><dt>KeyUp <span>[<span class="trigger-data"><span class="obj-name">Crafty's KeyboardEvent</span><span class="obj-props"> = { key: `Crafty.keys` keyCode (Number), originalEvent: original KeyboardEvent }</span></span>]</span></dt><dd>当 DOM 'keyup' 事件触发时在所有实体上触发。</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty Core</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>NewEntityName <span>[<span class="trigger-data"><span class="obj-name">entity name</span><span class="obj-props"> = {String}</span></span>]</span></dt><dd>当一个实体设置新名字后触发</dd></dl><dl class="trigger"><dt>NewComponent <span>[<span class="trigger-data"><span class="obj-name">Component</span><span class="obj-props"> = {String}</span></span>]</span></dt><dd>当实体添加新组件时触发</dd></dl><dl class="trigger"><dt>RemoveComponent <span>[<span class="trigger-data"><span class="obj-name">Component</span><span class="obj-props"> = {String}</span></span>]</span></dt><dd>当一个组件从实体移除时触发</dd></dl><dl class="trigger"><dt>Remove </dt><dd>当实体调用 .destroy() 销毁时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>.attr</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Change <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {key: value}</span></span>]</span></dt><dd>当属性变更时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.init</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Load </dt><dd>在视口初始化之后，EnterFrame循环启动之前触发。</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.stop</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>CraftyStop <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {bool clearState}</span></span>]</span></dt><dd>当游戏停止时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.pause</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Pause </dt><dd>当游戏暂停时触发</dd></dl><dl class="trigger"><dt>Unpause </dt><dd>当游戏从暂停状态继续时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.timer.steptype</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>NewSteptype <span>[<span class="trigger-data"><span class="obj-name">New steptype</span><span class="obj-props"> = { mode, maxTimeStep }</span></span>]</span></dt><dd>当前 steptype 变化时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.timer.step</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>EnterFrame <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { frame: Number, dt:Number }</span></span>]</span></dt><dd>每个帧触发。传递帧号和自上次帧以来的时间量。如果时间大于 maxtimestep，将使用 maxtimestep 代替。（maxtimestep的默认值是50毫秒。）</dd></dl><dl class="trigger"><dt>ExitFrame <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { frame: Number, dt:Number }</span></span>]</span></dt><dd>每个帧之后触发。传递帧号和自上次帧以来的时间量。如果时间大于 maxtimestep，将使用 maxtimestep 代替。（maxtimestep的默认值是50毫秒。）</dd></dl><dl class="trigger"><dt>PreRender </dt><dd>每次出现场景前立即触发。</dd></dl><dl class="trigger"><dt>RenderScene </dt><dd>每次渲染场景时触发。</dd></dl><dl class="trigger"><dt>PostRender </dt><dd>每次渲染场景后立即触发。</dd></dl><dl class="trigger"><dt>MeasureWaitTime <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {Number}</span></span>]</span></dt><dd>在第一步之后的每一步开始时触发。传递游戏在步骤之间的等待时间。</dd></dl><dl class="trigger"><dt>MeasureFrameTime <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {Number}</span></span>]</span></dt><dd>每个帧之后触发。传递前进一帧所需的时间。</dd></dl><dl class="trigger"><dt>MeasureRenderTime <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {Number}</span></span>]</span></dt><dd>

每次渲染后触发。传递渲染场景所需的时间 </dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.timer.FPS</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>FPSChange <span>[<span class="trigger-data"><span class="obj-name">new target FPS</span><span class="obj-props"> = {Number}</span></span>]</span></dt><dd>目标 FPS 被用户改变时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.e</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>NewEntity <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { id:Number }</span></span>]</span></dt><dd>当实体被创建并且所有组件添加后触发。</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.asset</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>NewAsset <span>[<span class="trigger-data"><span class="obj-name">key and value of new added asset.</span><span class="obj-props"> = {Object}</span></span>]</span></dt><dd>新资源被设置后触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Model</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Change </dt><dd>当模型数据改变时触发</dd></dl><dl class="trigger"><dt>Change[key] </dt><dd>当模型上特定的键值改变时触发</dd></dl><dl class="trigger"><dt>Change[key.key] </dt><dd>当嵌套的键值改变时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.scene</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>SceneChange <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { oldScene:String, newScene:String }</span></span>]</span></dt><dd>在新场景初始化之前触发</dd></dl><dl class="trigger"><dt>SceneDestroy <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { newScene:String  }</span></span>]</span></dt><dd>当前场景销毁前触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.s</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>SystemLoaded <span>[<span class="trigger-data"><span class="obj-name">system object</span><span class="obj-props"> = {obj}</span></span>]</span></dt><dd>当系统初始化之后触发</dd></dl><dl class="trigger"><dt>SystemDestroyed <span>[<span class="trigger-data"><span class="obj-name">system object</span><span class="obj-props"> = {obj}</span></span>]</span></dt><dd>在系统销毁之前触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Tween</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>TweenEnd <span>[<span class="trigger-data"><span class="obj-name">property</span><span class="obj-props"> = {String}</span></span>]</span></dt><dd>当一个 tween 完成时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>DebugCanvas</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>DebugDraw </dt><dd>当实体准备好绘制到舞台上时触发。</dd></dl><dl class="trigger"><dt>NoCanvas </dt><dd>当浏览器不支持 canvas 时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Canvas</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Draw <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {type: "canvas", pos, co, ctx}</span></span>]</span></dt><dd>当实体准备绘制到舞台上时触发</dd></dl><dl class="trigger"><dt>NoCanvas </dt><dd>当浏览器不支持 canvas 时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>.color</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd>当颜色改变时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>.DOM</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Draw <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { style:String, type:"DOM", co}</span></span>]</span></dt><dd>当实体准备绘制到舞台上时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>.image</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd>加载图像时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Particles</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>ParticleEnd </dt><dd>当粒子动画完成时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Renderable</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd>当实体需要重绘时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>.flip</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd>当实体翻转时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>.unflip</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd>当实体没有翻转时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>SpriteAnimation</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>StartAnimation <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {Reel}</span></span>]</span></dt><dd>当动画开始播放或者从暂停状态唤醒时触发</dd></dl><dl class="trigger"><dt>AnimationEnd <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { Reel }</span></span>]</span></dt><dd>当动画完成时触发</dd></dl><dl class="trigger"><dt>FrameChange <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { Reel }</span></span>]</span></dt><dd>每次当前序列的帧变化时触发</dd></dl><dl class="trigger"><dt>ReelChange <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { Reel }</span></span>]</span></dt><dd>当序列改变时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Sprite</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd>当精灵改变时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Text</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd>当文本改变时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>.textFont</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd></dd></dl></div></div></div><div class="eventPageBlock"><h4>.unselectable</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Invalidate </dt><dd></dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.viewport</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>ViewportScroll </dt><dd>当视口的 x 或 y 坐标改变时触发。</dd></dl><dl class="trigger"><dt>ViewportScale </dt><dd>当视口缩放时触发</dd></dl><dl class="trigger"><dt>ViewportResize </dt><dd>当视口的尺寸改变时触发</dd></dl><dl class="trigger"><dt>InvalidateViewport </dt><dd>当视口改变时触发</dd></dl><dl class="trigger"><dt>StopCamera </dt><dd>当任何一个摄像机动画停止时触发，例如开始一个新的动画。</dd></dl><dl class="trigger"><dt>CameraAnimationDone </dt><dd>当摄像机动画完成时触发。</dd></dl></div></div></div><div class="eventPageBlock"><h4>Crafty.viewport.reset</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>StopCamera </dt><dd>当摄像机动画被取消时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>WebGL</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Draw <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {type: "canvas", pos, co, ctx}</span></span>]</span></dt><dd>当实体准备要绘制到舞台时触发。</dd></dl><dl class="trigger"><dt>NoCanvas </dt><dd>当浏览器不支持 canvas 时触发。</dd></dl></div></div></div><div class="eventPageBlock"><h4>2D</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Move <span>[<span class="trigger-data"><span class="obj-name">Old position</span><span class="obj-props"> = { _x:Number, _y:Number, _w:Number, _h:Number }</span></span>]</span></dt><dd>当实体移动时触发。</dd></dl><dl class="trigger"><dt>Invalidate </dt><dd>当实体需要重绘时触发</dd></dl><dl class="trigger"><dt>Rotate <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { cos:Number, sin:Number, deg:Number, rad:Number, o: {x:Number, y:Number}}</span></span>]</span></dt><dd>当实体旋转时触发</dd></dl><dl class="trigger"><dt>Reorder </dt><dd>当实体的 z index 改变时触发。</dd></dl></div></div></div><div class="eventPageBlock"><h4>.offsetBoundary</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>BoundaryOffset </dt><dd>当 MBR 偏移改变时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>Collision</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>HitOn <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = { hitData }</span></span>]</span></dt><dd>当发生碰撞时触发。在碰撞结束前，这个事件将不会再触发，也可以要求再次触发(使用 `resetHitChecks(component)`).</dd></dl><dl class="trigger"><dt>HitOff <span>[<span class="trigger-data"><span class="obj-name">componentName</span><span class="obj-props"> = {String}</span></span>]</span></dt><dd>当指定的组件类型碰撞结束时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>.collision</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>NewHitbox <span>[<span class="trigger-data"><span class="obj-name">Data</span><span class="obj-props"> = {Crafty.polygon}</span></span>]</span></dt><dd>当一个新的碰撞盒子被分配时触发</dd></dl></div></div></div><div class="eventPageBlock"><h4>AngularMotion</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Rotated <span>[<span class="trigger-data"><span class="obj-name">Old rotation</span><span class="obj-props"> = {Number}</span></span>]</span></dt><dd>当由于角速度/加速度变化导致实体旋转时事件被触发</dd></dl><dl class="trigger"><dt>NewRotationDirection <span>[<span class="trigger-data"><span class="obj-name">New direction</span><span class="obj-props"> = {-1 | 0 | 1}</span></span>]</span></dt><dd>当实体改变旋转方向导致旋转速度 NewrotationDirection 事件触发。如果方向不同于上一帧，则事件触发一次。</dd></dl><dl class="trigger"><dt>MotionChange <span>[<span class="trigger-data"><span class="obj-name">Motion property name and old value</span><span class="obj-props"> = { key: String, oldValue: Number }</span></span>]</span></dt><dd>

当一个运动的性质已经改变了 MotionChange 事件触发。 </dd></dl></div></div></div><div class="eventPageBlock"><h4>Motion</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>Moved <span>[<span class="trigger-data"><span class="obj-name">Old position</span><span class="obj-props"> = { axis: 'x' | 'y', oldValue: Number }</span></span>]</span></dt><dd>当实体在X或Y轴上由于速度/加速度而移动时，就会触发移动事件。如果实体移动了两个对角线移动的轴，事件就会触发两次。</dd></dl><dl class="trigger"><dt>NewDirection <span>[<span class="trigger-data"><span class="obj-name">New direction</span><span class="obj-props"> = { x: -1 | 0 | 1, y: -1 | 0 | 1 }</span></span>]</span></dt><dd>当实体在x轴或者y轴上改变了运动方向就会触发。如果方向不同于上一帧，则事件触发一次。</dd></dl><dl class="trigger"><dt>MotionChange <span>[<span class="trigger-data"><span class="obj-name">Motion property name and old value</span><span class="obj-props"> = { key: String, oldValue: Number }</span></span>]</span></dt><dd>当运动的属性改变时触发。</dd></dl></div></div></div><div class="eventPageBlock"><h4>Supportable</h4><div class="triggered-events"><div class="trigger-list"><dl class="trigger"><dt>LandedOnGround </dt><dd>当实体着陆时触发，该事件是有着陆的实体发出的。</dd></dl><dl class="trigger"><dt>LiftedOffGround </dt><dd>当实体剥离时。这个事件是由物体在升空之前触发的。</dd></dl><dl class="trigger"><dt>CheckLanding </dt><dd>如果实体即将着陆。事件将在实体着陆时触发。第三方可以响应此事件决定实体能否着陆。</dd></dl></div></div></div></div></div></div>
			
		</div>
	</div>
	<div class="clearer"></div>
	<div id="footer">
		<div id="contact">
			<a href="https://groups.google.com/forum/#!forum/craftyjs">
				<img src="../images/google.png">
				google groups</a>
			<a href="mailto:starwed@gmail.com">
				<img src="../images/email.png">
				starwed@gmail.com</a>
			<a href="https://github.com/craftyjs/Crafty">
				<img src="../images/github.png">
				github</a>
		</div>
		<ul>
			<li><a href="../">首页</a></li>
				<li><a href="../getting-started/">快速开始</a></li>
				<li><a href="../documentation/">文档</a></li>
				<li><a href="../api/">API</a></li>
				<li><a href="../components/">组件</a></li>
				<li class="emph"><a href="../#install">下载</a></li>
		</ul>
		<p>
			© Crafty 2010-2015. Crafty is distributed under the <a href="http://en.wikipedia.org/wiki/MIT_License">MIT License</a>.
		</p>
	</div>
</div>


</body></html>